home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / •New Files / AuthenticateCracker / source.c < prev   
C/C++ Source or Header  |  1999-06-12  |  2KB  |  131 lines

  1. #include <Fonts.h>
  2. #include <Menus.h>
  3. #include <textedit.h>
  4. #include <Dialogs.h>
  5. #include <windows.h>
  6. #include <SegLoad.h>
  7. #include <ToolUtils.h>
  8. #include <Resources.h>
  9. #include <quickdraw.h>
  10. #include <traps.h>
  11. #include <Devices.h>
  12. #include <string.h>
  13. #include <StandardFile.h>
  14. #include <Files.h>
  15.  
  16.  
  17.  
  18. void main(void); 
  19. void doInitManagers            (void); /*initalizes mac tool boxes*/
  20. void doDecrypt(void);
  21.  
  22.  
  23.  
  24. void  main(void)
  25. {        
  26.     MaxApplZone();
  27.     doInitManagers();
  28.     doDecrypt();
  29. }
  30.  
  31.  
  32.  
  33. void  doInitManagers(void)
  34. {
  35.     InitGraf((Ptr) &qd.thePort);
  36.     InitFonts();
  37.     InitWindows();
  38.     InitMenus();
  39.     TEInit();
  40.     InitDialogs(nil);
  41.     InitCursor();
  42. }
  43.  
  44.  
  45. void doDecrypt(void)
  46. {
  47. SFTypeList                 myTypelist;
  48. StandardFileReply         mySFR,myReply;
  49. short                     fsRefNum,myRefNumber;
  50. OSErr                     fsopenErr,osError;
  51. SInt32                    numberOfBytes,tempNOB;
  52. Handle                    textBuffer;
  53. char    *text;
  54. char    textbuffer;
  55.  
  56.  
  57.     myTypelist[0] = 'pref';
  58.     
  59.     StandardGetFile (nil,1,myTypelist,&mySFR);
  60.     
  61.     if(mySFR.sfGood)
  62.     {
  63.         fsopenErr = FSpOpenDF(&mySFR.sfFile,fsCurPerm,&fsRefNum);
  64.     }
  65.     
  66.     else{
  67.             ExitToShell();
  68.         }
  69.         
  70.     GetEOF(fsRefNum,&numberOfBytes);
  71.     
  72.     if(!(textBuffer = NewHandle((Size) numberOfBytes)))
  73.         ExitToShell();
  74.         
  75.     osError = FSRead(fsRefNum,&numberOfBytes,*textBuffer);
  76.     
  77.     if(osError == noErr || osError == eofErr)
  78.     {
  79.         text = *textBuffer;
  80.         
  81.         tempNOB=numberOfBytes;
  82.         
  83.         while (tempNOB != 0) 
  84.             {
  85.             textbuffer = *text;
  86.             textbuffer = textbuffer^0xaa;
  87.             *text=textbuffer;
  88.             tempNOB--;
  89.             text++;
  90.             }
  91.             
  92.         text -= numberOfBytes;
  93.  
  94.         StandardPutFile("\pSave cracked file as:","\pcrack.txt",&myReply);
  95.         
  96.         if(myReply.sfGood)     
  97.         {
  98.             if(!(myReply.sfReplacing))
  99.             {  
  100.                 osError = FSpCreate(&myReply.sfFile,'ttxt','TEXT',smSystemScript);
  101.                 if(osError != noErr) {
  102.                     ExitToShell();}
  103.             }
  104.             
  105.             osError = FSpOpenDF(&myReply.sfFile,fsRdWrPerm,&myRefNumber);
  106.                 if(osError != noErr) {
  107.                     ExitToShell();}
  108.                 
  109.             osError = FSWrite(myRefNumber,&numberOfBytes,text);
  110.             if(osError != noErr) {
  111.                 ExitToShell();}
  112.             
  113.  
  114.             osError = FSClose(myRefNumber);
  115.                 if(osError != noErr) {
  116.                     ExitToShell();}
  117.             
  118.         
  119.         } /*end of if*/        
  120.     
  121.     
  122.     }
  123.     else {
  124.     
  125.     ExitToShell();
  126.     
  127.     }
  128.     ExitToShell();
  129. }
  130.  
  131.